// https://www.jianshu.com/p/3d6d0ca06f21
// 指令注册于导出
// 引入Directive 和 app
import type { App, Directive } from 'vue';
import permission from './permission';
import focus from './focus';
// 放入类中
const directives = {
	permission,
	focus,
};
// 注册指令
export const registerDirective = (app: App) => {
	Object.keys(directives).forEach((key) => {
		app.directive(key, (directives as { [key: string]: Directive<HTMLElement, string> })[key]);
	});
};

function useDirective(app: App) {
	registerDirective(app);
}

export default useDirective;
